import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

async function main(): Promise<void> {
  const rows = await prisma.rewardDistributionStatus.findMany({
    orderBy: { date: 'desc' },
    take: 5
  })

  if (rows.length === 0) {
    console.log('reward_distribution_statuses 表暂无记录')
    return
  }

  rows.forEach((row) => {
    console.log({
      date: row.date.toISOString(),
      distributionCount: row.distributionCount,
      lastDistributionAt: row.lastDistributionAt?.toISOString() ?? null,
      nextDistributionAt: row.nextDistributionAt?.toISOString() ?? null
    })
  })
}

main()
  .catch((error) => {
    console.error(error)
    process.exitCode = 1
  })
  .finally(async () => {
    await prisma.$disconnect()
  })
